import CryptoJS from 'crypto-js';
import Base64 from 'base-64';
import { getUUID } from './tools.js'
import { key } from '@/common/baseconfig.js'
const keys = CryptoJS.enc.Utf8.parse(key);
const encrypt =  (message) => {
	const ciphertext = CryptoJS.AES.encrypt(message, keys, {
		mode: CryptoJS.mode.ECB,
		padding: CryptoJS.pad.Pkcs7,
	});
	const hexString = ciphertext.ciphertext.toString(CryptoJS.enc.Hex);
	return hexString;
};



const encrypt2 =  (message) => {
	return  Base64.encode(message)
};



const decrypt =  (word) => {
	return Base64.decode(word)
}

export {
	encrypt,
	encrypt2,
	decrypt
}


// export default { //加密
// 	// qwerrtyhfgfbvvcfdffd 
// 	encrypt(word, keyStr = str) {
// 		let key = CryptoJS.enc.Utf8.parse(keyStr); //Latin1 w8m31+Yy/Nw6thPsMpO5fg==
// 		let srcs = CryptoJS.enc.Utf8.parse(word);
// 		let encrypted = CryptoJS.AES.encrypt(srcs, key, {
// 			mode: CryptoJS.mode.ECB,
// 			padding: CryptoJS.pad.Pkcs7
// 		});
// 		return encrypted.toString();
// 	},
// 	//解密
// 	decrypt(word, keyStr = str) {
// 		let key = CryptoJS.enc.Utf8.parse(keyStr); //Latin1 w8m31+Yy/Nw6thPsMpO5fg==
// 		let decrypt = CryptoJS.AES.decrypt(word, key, {
// 			mode: CryptoJS.mode.ECB,
// 			padding: CryptoJS.pad.Pkcs7
// 		});
// 		return CryptoJS.enc.Utf8.stringify(decrypt).toString();
// 	}

// }
